﻿// -----------------------------------------------------------------------
// <copyright file="IPushRequestService.cs" company="Zen Design Corp">
// TODO: Update copyright text.
// </copyright>
// -----------------------------------------------------------------------

namespace Zen.BlackBerry.Push.Request
{
	using System;
	using System.Collections.Generic;
	using Zen.BlackBerry.Common;
	using Zen.BlackBerry.Pap;
	using Zen.BlackBerry.Pap.Parser;

	/// <summary>
	/// Interface defining data access methods needed to manage
	/// <see cref="T:PushRequestDetail"/> objects in the persistent store.
	/// </summary>
	public interface IPushRequestDetailRepository
	{
		/// <summary>
		/// Adds the specified push request detail to the persistent store.
		/// </summary>
		/// <param name="pushRequestDetail">The push request detail.</param>
		void AddPushRequestDetail(PushRequestDetail pushRequestDetail);

		/// <summary>
		/// Adds the specified push request details to the persistent store.
		/// </summary>
		/// <param name="pushRequestDetails">The push request details.</param>
		void AddPushRequestDetails(IEnumerable<PushRequestDetail> pushRequestDetails);

		/// <summary>
		/// Finds all push request details by the specified created-date range.
		/// </summary>
		/// <param name="fromDate">From date.</param>
		/// <param name="toDate">To date.</param>
		/// <param name="startIndex">The start index.</param>
		/// <param name="endIndex">The end index.</param>
		/// <returns></returns>
		IEnumerable<PushRequestDetail> FindByDateRange(DateTime fromDate, DateTime toDate, int startIndex, int endIndex);

		/// <summary>
		/// Finds all the push request details for the specific push request.
		/// </summary>
		/// <param name="id">The id.</param>
		/// <returns></returns>
		IEnumerable<PushRequestDetail> FindById(string id);

		/// <summary>
		/// Finds a push request detail by the specified push request and address.
		/// </summary>
		/// <param name="id">The id.</param>
		/// <param name="address">The address.</param>
		/// <returns></returns>
		PushRequestDetail FindByIdAndAddress(string id, string address);

		/// <summary>
		/// Finds push request details by the specified push request and addresses.
		/// </summary>
		/// <param name="id">The id.</param>
		/// <param name="addresses">The addresses.</param>
		/// <returns></returns>
		IEnumerable<PushRequestDetail> FindByIdAndAddresses(string id, IEnumerable<string> addresses);

		/// <summary>
		/// Finds all the push request details for the specific push request and given states.
		/// </summary>
		/// <param name="id">The id.</param>
		/// <param name="states">The states.</param>
		/// <returns></returns>
		IEnumerable<PushRequestDetail> FindByIdAndStates(String id, IEnumerable<MessageState> states);

		/// <summary>
		/// Finds all the push request details with the given status code for a specific push request.
		/// </summary>
		/// <param name="id">The id.</param>
		/// <param name="statusCode">The status code.</param>
		/// <returns></returns>
		IEnumerable<PushRequestDetail> FindByIdAndStatusCode(String id, StatusCode statusCode);

		/// <summary>
		/// Finds push request details by the specified push request and subscriber ids.
		/// </summary>
		/// <param name="id">The id.</param>
		/// <param name="subscriberIds">The subscriber ids.</param>
		/// <returns></returns>
		IEnumerable<PushRequestDetail> FindByIdAndSubscriberIds(string id, IEnumerable<string> subscriberIds);

		/// <summary>
		/// Finds push ids and application ids for the specific push requests and given state.
		/// </summary>
		/// <param name="ids">The ids.</param>
		/// <param name="state">The state.</param>
		/// <returns></returns>
		IEnumerable<PushIdAndApplicationId> FindByIdsAndState(IEnumerable<string> ids, MessageState state);

		/// <summary>
		/// Finds all the push request details by the specified status code.
		/// </summary>
		/// <param name="statusCode">The status code.</param>
		/// <param name="startIndex">The start index.</param>
		/// <param name="endIndex">The end index.</param>
		/// <returns></returns>
		IEnumerable<PushRequestDetail> FindByStatusCode(StatusCode statusCode, int startIndex, int endIndex);

		/// <summary>
		/// Finds all push requests that are incomplete for a specific subscriber id and push application.
		/// </summary>
		/// <param name="applicationId">The application id.</param>
		/// <param name="subscriberId">The subscriber id.</param>
		/// <returns></returns>
		IEnumerable<PushRequestDetail> FindIncompleteByAppIdAndSubId(string applicationId, string subscriberId);

		/// <summary>
		/// Gets size of all push request details by the specified date range.
		/// </summary>
		/// <param name="fromDate">From date.</param>
		/// <param name="toDate">To date.</param>
		/// <returns></returns>
		int GetSizeByDateRange(DateTime fromDate, DateTime toDate);

		/// <summary>
		/// Updates the specified push request detail in the persistent store.
		/// </summary>
		/// <param name="pushRequestDetail">The push request detail.</param>
		void UpdatePushRequestDetail(PushRequestDetail pushRequestDetail);

		/// <summary>
		/// Updates the push request details based on the specified list of push request details.
		/// </summary>
		/// <param name="pushRequestDetails">The push request details.</param>
		void UpdatePushRequestDetails(IEnumerable<PushRequestDetail> pushRequestDetails);

		/// <summary>
		/// Updates the push request details based on the specified list of push request details.
		/// </summary>
		/// <param name="pushRequestDetails">The push request details.</param>
		void UpdatePushRequestDetailsWithoutAddresses(IEnumerable<PushRequestDetail> pushRequestDetails);
	}
}
